import os

for line in os.popen("grep '\[Dish\ Name\]' ./recipes/*.md").read().split("\n"):
    if ":" not in line: continue
    fname, cont = line.split(":")
    if cont != '**[Dish Name]**': continue
    flag = False
    out = []
    for line in open(fname,"r"):
        if flag == True:
            if len(line.strip()) == 0: continue
            if line.startswith("**"): out.append(line.strip())
            else: out.append("**"+line.strip()+"**")
            flag = False
            continue
        if line.strip() == "**[Dish Name]**":
            flag = True
            continue
        out.append(line.strip())
    fname1 = fname.replace("md","md1")
    with open(fname1,"w") as f: f.write("\n".join(out))
    cmd = "mv " + fname1 + " " + fname
    os.system(cmd)
    print(cmd)
